package requestProcesser;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.RequestProcessor;

public class femaRequestProcessor extends RequestProcessor{
	
	protected ActionForward processActionPerform(HttpServletRequest request,
			HttpServletResponse response, Action action, ActionForm form,
			ActionMapping mapping) throws IOException, ServletException {
	
		String permission = null;
		
		String allPermissions = (String)request.getParameter("permissionName");
		
		
		try{
			permission = mapping.getPath();
			
			RequestProcessor test = new RequestProcessor();
			
			
		
		
		if("Login.do".equals(permission) ||
				"signout.do".equals(permission) || "forgotpwd.do".equals(permission)|| 
				"changePWD.do".equals(permission) || "doGetAddRegister.do".equals(permission) 
				|| "saveRegistration.do".equals(permission)){
		//	return true;
		}
		
		ActionForward af = new ActionForward();
		}catch(Exception e){
			e.printStackTrace();
		}
		 return super.processActionPerform(request, response, action, form,mapping);
	}
	
	
	
	
	protected  boolean processRoles(HttpServletRequest request, HttpServletResponse response,ActionMapping mapping)throws IOException, ServletException { 
			 try { 
				
				System.out.print("processRolse() Started--------->>>");
				
				femaActionMapping fmMapping = (femaActionMapping) mapping;
				String parentPermission = null != fmMapping.getPermissionName()?fmMapping.getPermissionName():"";
				
				
				String[] parentPermission1 = parentPermission.split(",");
				
				
				if(!"".equals(parentPermission)){
				/*parentPermission = parentPermission.substring(0, parentPermission.length() - 3);*/
				
				String permissionName = mapping.getPath().substring(1);
				
				if("Login.do".equals(parentPermission) ||
						"signout.do".equals(parentPermission) || "forgotpwd.do".equals(parentPermission)|| 
						"changePWD.do".equals(parentPermission) || "doGetAddRegister.do".equals(parentPermission) 
						|| "saveRegistration.do".equals(parentPermission)){
					return true;
				}
				
				if(!parentPermission.contains(permissionName)){
					return false;
					
				}
				}
				/*getRequestProcessor().processRequest(request); 
			
			
			
			    getScreenFlowManager().forwardToNextScreen(request, response); */
			
			
		
			}catch(Exception e){
				e.printStackTrace();
				return false;
			}
			 return true;	
	}
	    
            

}
